<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
	<title>考试报名</title>
	<link th:replace="~{common::common_head}">
</head>

<body class="">
<div class="wrapper">
	<div th:insert="~{common::sidebar(active='signup.html')}"></div>
	<div class="main-panel">
		<!-- Navbar导航栏 -->
		<nav th:replace="~{common::navbar}"></nav>
		<!-- End Navbar -->
		<div class="panel-header">
			<div class="header text-center">
				<h2 class="title">报名考试</h2>
				<p class="category">仅供模拟生成准考证报名。</p>
			</div>
		</div>
		<div class="content">
			<div class="row">
				<div class="col-md-8 offset-2">
					<div class="card">
						<div class="card-header">
							<h5 class="title">学生报名</h5>
							<h3 class="text-center text-danger" th:text="${msg==null?'&nbsp':msg}"></h3>
						</div>
						<div class="card-body">
							<form id="signup_form">
								<!--隐藏域-->
								<input type="text" name="id" hidden="hidden">
								<select id="school" name="school" class="form-control offset-2 col-8 mb-3" onchange="checkInfo()">
									<option selected disabled="disabled">考点选择</option>
									<option value="河南财经政法大学">河南财经政法大学</option>
									<option value="郑州科技学院">郑州科技学院</option>
									<option value="华北水利水电大学">华北水利水电大学</option>
									<option value="郑州大学">郑州大学</option>
									<option value="郑州轻工业大学">郑州轻工业大学</option>
									<option value="河南工业大学">河南工业大学</option>
									<option value="中原工学院">中原工学院</option>
									<option value="河南农业大学">河南农业大学</option>
									<option value="河南牧业经济学院">河南牧业经济学院</option>
									<option value="河南中医药大学">河南中医药大学</option>
									<option value="郑州工商学院">郑州工商学院</option>
									<option value="郑州升达经贸管理学院">郑州升达经贸管理学院</option>
								</select>
								<select id="grade" name="level" class="form-control offset-2 col-8 mb-3" onchange="checkInfo()">
									<option selected disabled="disabled">等级选择</option>
									<option value="英语四级">英语四级</option>
									<option value="英语六级">英语六级</option>
								</select>
								<div class="col-8 offset-2">
								<button id="btnSubmit" disabled="disabled" class="btn btn-lg btn-primary" onclick="signup()" style="width: 100%" type="button">报名</button></div>
							</form>
							<p class="mt-5 mb-1 ml-2 col-sm-12 text-info">本系统只提供模拟准考证生成</p>
							<p class="ml-2 mb-1 col-sm-12 text-info">如需正式报名请访问英语四六级报名官网进行报名</p>
							<p class="text-center mt-3 mb-1 col-sm-12 text-black">CETMANAGEMENTSYSTEM @Copyright Aurora 2020-2021</p>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!--底部footer-->
		<footer th:replace="~{common::footer}"></footer>
	</div>
</div>
<!--通用footerJs-->
<script th:replace="~{common::footerJs}"></script>

<script>
	var schoolSelect = document.getElementById('school');
	var gradeSelect = document.getElementById('grade');
	var submitBtn = document.getElementById('btnSubmit');
	function checkInfo(){
		if (getSelectValue(schoolSelect) != '考点选择' && getSelectValue(gradeSelect) != '等级选择'){
			submitBtn.disabled = '';
		}
	}
	function getSelectValue(select){
		// var select = document.getElementById('select'); //定位id
		var index = select.selectedIndex; // 选中索引
		var text = select.options[index].text; // 选中文本
		var selectValue = select.options[index].value; // 选中值
		return selectValue;
	}

	/**
	 * 提交报名信息
	 */
	function signup(){
		var formData = $("#signup_form").serialize();
		$.ajax({
			sync:false,
			url:'/student/signUp/print',
			data: formData,
			method:'post',
			dataType:'text',
			success:function(result){
				if(result==='报名成功！'){
					demo.showNotification('success',result);
					setTimeout(function (){
						window.location = '/student/toTicket'
					},1000)
					return;
				}
				demo.showNotification('danger',result);
			}
		})

	}

</script>


</body>
</html>
